package kr.co.xosoft.adapter;

import java.util.ArrayList;

import kr.co.xosoft.R;

import android.content.Context;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

public class ServerChkSetupAdapter extends ArrayAdapter<Object>{
	private Context context;
	private ArrayList<Object> list;
	Resources res;
	
	public ServerChkSetupAdapter(Context context, int layoutId, ArrayList<Object> list, Resources res) {
		super(context, layoutId, list);
		this.context = context;
		this.list = list;
		this.res = res;
	}
	
	@Override
	public int getCount() {
		return super.getCount();
	}
	
	@Override
	public Object getItem(int position) {
		return super.getItem(position);
	}
	
	@Override
	public int getPosition(Object item) {
		return super.getPosition(item);
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View row = convertView;
		if(row == null){
			if(position == 1){
				LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
				row = inflater.inflate(R.layout.sttaeview, null);
				CheckBox cb = (CheckBox)row.findViewById(R.id.st_cb01);
				cb.setChecked((Boolean)getItem(1));
			}else{
				LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
				row = inflater.inflate(R.layout.sttonlyview, null);
				TextView tv = (TextView)row.findViewById(R.id.st_tv01);
				if(position == 2){
					tv.setText(res.getString(R.string.setup_syncTime));
					tv.setEnabled((Boolean)getItem(1));
				}else{
					tv.setText(res.getString(R.string.setup_viewTypeName));
				}
			}
		}
		return row;
	}
}
